<template>
	<view v-if="IsShowMain">
		<view class='main'>
			<view class='basicdesc'>
				<view @click="showImage" class='l-item'><image class='logo' :src="list.image"></image></view>
				<view class='r-item'>
					<view>姓名：{{list.name}}</view>
					<view>性别：{{list.gender}}</view>
					<view>年龄：{{list.age}}岁</view>
					<view>工种：{{list.work}}</view>
				</view>
			</view>
			<view class="desc">
				<view>期望薪资：{{list.expect_pay}}万韩元/天</view>
				<view class="exp">{{list.desc}}</view>
			</view>
			<view class="call" @click="contact">速度联系</view>
		</view>
		<view class="tips">
			<text style="color:#ff0000;margin: 0 20upx;">*</text>
			只有企业身份才能联系职工哦，可以在我的资料里查看当前的身份信息，也可以在线咨询客服升级权限
		</view>
	</view>
</template>

<script>
	import api from '@/pages/utils/api.js';
	export default{
		data() {
			return {
				job_id:'',
				list:{},
				showImg:[],
				IsShowMain:false
			}
		},
		onLoad(e) {
			this.job_id = e.id;
			this.getJobDetail();
		},
		onShow() {
			if(uni.getStorageSync('checked_status') == 1){
				uni.navigateTo({
					url: '/pages/index/checked'
				});
				return;
			};
			this.IsShowMain = true
		},
		methods: {
			contact:function(){
				var vm = this;
				wx.getSetting({ //判断是否授权
				  success (res){
						if (!res.authSetting['scope.userInfo']) 
						{
							uni.showModal({
								title: '系统提示',
								confirmText:'去授权',
								content: '需要授权才能联系职工哦',
								success: function (res) {
									if (res.confirm) {
									   uni.navigateTo({
										url: '/pages/auth/index'
									   });
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});
						 }else{
							let current_identity = uni.getStorageSync('identity');//获取当前用户身份
							if(current_identity != 1){
								uni.showModal({
									 title: '系统提示',
									 showCancel: false,
									 content: '当前你为工人，联系客服升级权限',
									 success: function (res) {
									 }
								})
								return false;
							}else{
								uni.navigateTo({
								    url: "/pages/index/contact?id="+vm.job_id
								});
							}
							
						 }
					}
				})
			},
			
			//职工详情
			getJobDetail:function(){
				var vm = this;
				api.getJobDetail({
					job_id:vm.job_id
				}).then(info=>{
					if(info.code == 1){
						this.IsShowMain = true;
						vm.list = {
							image:info.data.image,
							name:info.data.realname,
							gender:info.data.gender == 1 ? '男' : '女',
							age:info.data.birthday,
							work:info.data.profession.title,
							expect_pay:info.data.expect_pay,
							desc:info.data.work
						};
						vm.showImg.push(info.data.image);
					}
				})
			},
			//头像预览
			showImage:function(){
				var vm = this;
				wx.previewImage({
				  current: vm.showImg, // 当前显示图片的http链接
				  urls: vm.showImg // 需要预览的图片http链接列表
				})
			}
		}
	}
</script>

<style>
	.basicdesc{
		display: flex;
		align-items: center;
		
	}
	.logo{
		width: 240upx;
		height: 240upx;
		border-radius: 10upx;
	}
	.main{
		width: 90%;
		height: 1000upx;
		margin: 20upx auto;
		box-shadow: 0 0 2upx 2upx #C9C9C9;
		border-radius: 10upx;
		color:#8F8F8F;
		padding: 20upx;
	}
	.r-item{ 
		padding: 0 10upx;
		line-height: 60upx;
		margin-left: 50upx; 
	}
	.desc{
		margin: 30upx 0;
	}
	.desc view{
		margin: 20upx 0;
	}
	.exp{
		line-height: 55upx;
	}
	.call{
		background: #F7AE2B;
		color:#FFF;
		border-radius: 10upx;
		width: 70%;
		margin: 150upx auto 0 auto;
		text-align: center;
		padding: 20upx 0;
	} 
	.tips{
		font-size: 26upx;
		color:#666;
		padding: 20upx;
	}
</style>
